/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tnmk.worktime.gui.list;

import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
import org.joda.time.DateTime;
import org.tnmk.worktime.config.AppConfig;

/**
 *
 * @author Administrator
 */
public class ListDateTimeRenderer extends DefaultListCellRenderer {

  @Override
  public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    JLabel comp = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (value instanceof DateTime) {
      DateTime dt = (DateTime) value;
      String dts = AppConfig.toString(dt);
      comp.setText(dts);
    }
    return comp;
  }

}
